import { actionTypes } from '../store'
import axios from 'axios'

const setData=(value)=>({
    type:actionTypes.CHANGE_LIST,
    value,
    totalPage:Math.ceil(value.length/10)
});

export const searchFocus=()=>({
    type:actionTypes.SEARCH_FOCUS
});

export const searchBlur=()=>({
    type:actionTypes.SEARCH_BLUR
});

export const mouseEnter=()=>({
    type:actionTypes.MOUSE_ENTER
});

export const mouseLeave=()=>({
    type:actionTypes.MOUSE_LEAVE
});

export const changeList=(value)=>({
    type:actionTypes.CHANGE_INFOLIST,
    value
});


export const getList=()=>{
    return(dispatch)=>{
        axios.get('/api/headerList.json').then((res)=>{
            const data=res.data.data;
            dispatch(setData(data))
        }).catch((err)=>{
                console.log(err)
        })
    }
};




